const AsyncMysqljs = require('../mysql/index')
const Query = AsyncMysqljs().query

module.exports = async (ctx, next) => {
    const { id } = ctx.request.body
    const sql = 'UPDATE film SET is_show=? WHERE id=?'
    if(!id) {
        ctx.body = {
            code: 1,
            data: {},
            msg: 'id字段为空！'
        }
        return
    }
    try {
        const doc = await Query(sql, [0, id])
        ctx.body = {
            code: 1,
            data: {},
            msg: '删除成功！'
        }
    } catch (error) {
        ctx.body = {
            code: 0,
            data: {},
            error: error,
            msg: '删除失败！'
        }
    }
    
}